package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.Phone;
import com.ruoyi.system.mapper.CarsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DriversMapper;
import com.ruoyi.system.domain.Drivers;
import com.ruoyi.system.service.IDriversService;

/**
 * 司机Service业务层处理
 * 
 * @author he
 * @date 2025-08-06
 */
@Service
public class DriversServiceImpl implements IDriversService 
{
    @Autowired
    private DriversMapper driversMapper;

    @Autowired
    private CarsMapper carsMapper;

    /**
     * 查询司机
     * 
     * @param id 司机主键
     * @return 司机
     */
    @Override
    public Drivers selectDriversById(Long id)
    {
        return driversMapper.selectDriversById(id);
    }

    /**
     * 查询司机列表
     * 
     * @param drivers 司机
     * @return 司机
     */
    @Override
    public List<Drivers> selectDriversList(Drivers drivers)
    {
        return driversMapper.selectDriversList(drivers);
    }

    /**
     * 新增司机
     * 
     * @param drivers 司机
     * @return 结果
     */
    @Override
    public int insertDrivers(Drivers drivers)
    {

        return driversMapper.insertDrivers(drivers);
    }

    /**
     * 修改司机
     * 
     * @param drivers 司机
     * @return 结果
     */
    @Override
    public int updateDrivers(Drivers drivers)
    {

        return driversMapper.updateDrivers(drivers);
    }

    /**
     * 批量删除司机
     * 
     * @param ids 需要删除的司机主键
     * @return 结果
     */
    @Override
    public int deleteDriversByIds(Long[] ids)
    {
        return driversMapper.deleteDriversByIds(ids);
    }

    /**
     * 删除司机信息
     * 
     * @param id 司机主键
     * @return 结果
     */
    @Override
    public int deleteDriversById(Long id)
    {
        return driversMapper.deleteDriversById(id);
    }

    @Override
    public List<Drivers> getDriverInfoList(String paramName) {

        return driversMapper.getDriverInfoList(paramName);

    }

    @Override
    public Phone driverInfoPhone(String fwid) {

//        Long userId = SecurityUtils.getUserId();
        return driversMapper.driverInfoPhone(fwid);
    }

    @Override
    public int updateDriverPhone(Phone phone) {
        Long userId = SecurityUtils.getUserId();
        phone.setUserId(userId);
        phone.setUpdateTime(DateUtils.getNowDate());
        driversMapper.updateDriverPhone(phone);

        return carsMapper.updateCarPhone(phone);

    }
}
